<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
		<title>成本付款审核单</title>		
		
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
			<script type="text/javascript" src="static/js/jquery-1.7.2.js" />
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
			<link rel="stylesheet" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
			
			
</head>
<body>
<!-- <div id="payment"></div> -->
<!-- <div id="payment1"></div> -->
<!-- <div id="payment2"></div> -->
<!-- <div id="payment1"></div> -->
<!-- <div id="payment11"></div> -->
<!-- <div id="payment21"></div> -->

</body>
<script type="text/javascript">
Ext.onReady(function(){
	Ext.QuickTips.init();
 
Ext.define('store', {
	extend : 'Ext.data.Model',
	
	fields :[{
   		name:'id'
   	},{
   		name:'loan_id'
   	},{
   		name:'invoice_code'
   	},{
   	    name: 'bill_code'
   	},{
   	    name : 'payment_amount'
   	},{
   	    name : 'fee_name'
   	},{
   	    name : 'loan_odd_code'
   	},{
   	    name : 'loan_date'
   	},{
   	    name : 'loan_amount'
   	},{
   	    name : 'remark'
   	},{
   	    name : 'is_cost_audit'
   	},{
   		name : 'currency'
   	}
   	
   	]
});
var store = Ext.create('Ext.data.Store', {
	model : 'store',
	pageSize:10,
	id:'store',
	proxy: {
		type: 'ajax',
		url: '<%=basePath%>costCheckList/findPaymentInfo',
		reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
			type: 'json', //返回数据类型为json格式
			root: 'result.list',  //数据
			totalProperty: 'result.total' //数据总条数
		}
	},
	
});
// store.load({ params:{start : 0,limit : 10}}); 
Ext.define('store2', {
	extend : 'Ext.data.Model',
	
	fields :[{
   		name:'costId'
   	},{
   		name:'incomeId'
   	},{
   		name:'invoice_code'
   	},{
   	    name: 'bill_code'
   	},{
   	    name : 'payment_amount'
   	},{
   	    name : 'fee_name'
   	},{
   	    name : 'receipt_code'
   	},{
   	    name : 'receipt_date'
   	},{
   	    name : 'receipt_amount'
   	},{
   	    name : 'remark'
   	},{
   	    name : 'is_cost_audit'
   	},{
   		name : 'currency'
   	}
   	
   	]
});
var store2 = Ext.create('Ext.data.Store', {
	model : 'store2',
	pageSize:10,
	id:'store2',
	proxy: {
		type: 'ajax',
		url: '<%=basePath%>costCheckList/findIncomeInfoBy',
		reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
			type: 'json', //返回数据类型为json格式
			root: 'result.list',  //数据
			totalProperty: 'result.total' //数据总条数
		}
	},
	
});
var businessType = Ext.create('Ext.data.Store', {
	fields: ['id', 'name'],
	data : [
		{"id":"", "name":"请选择"},
		{"id":"1", "name":"货代"},
		{"id":"2", "name":"船代"},
		{"id":"3", "name":"航运"},
		{"id":"4", "name":"租船"},
		{"id":"5", "name":"综合物流"},
		{"id":"6", "name":"其他"},
		{"id":"7", "name":"支线"},
		{"id":"8", "name":"内贸"},
		{"id":"9", "name":"项目"}
	]
});
var currency = Ext.create('Ext.data.Store', {
	fields: ['id', 'name'],
	data : [
		{"id":"", "name":"请选择"},
		{"id":"1", "name":"RMB"},
		{"id":"2", "name":"USD"}
	]
});
var store1 = Ext.create('Ext.data.Store', {
	fields: ["id",
	         "payment_app_code",
	         "payment_bill_date",
	         "payment_app_dept",
	         "dept_business_type",
	         "settlement_dept",
	         "deposit_bank",
	         "bank_account",
	         "payment_term",
	         "invoice_code",
	         "bill_code",
	         "payment_amount",
	         "fee_name",
	         "loan_odd_code",
	         "loan_date",
	         "loan_amount",
	         "receipt_code",
	         "receipt_date",
	         "receipt_amount",
	         "general_manager",
	         "financial_accounting",
	         "division_vice_president",
	         "dept_manager",
	         "financial_vice_president",
	         "business_manager",
	         "business_handler",
	         "payment_app_person",
	         "remark"],
	pageSize: 30,  //页容量5条数据
	//是否在服务端排序 （true的话，在客户端就不能排序）
	remoteSort: false,
	remoteFilter: true,
	proxy: {
		type: 'ajax',
		url: '<%=basePath%>costCheckList/internalTradeBaseInfo',
		reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
			type: 'json', //返回数据类型为json格式
			root: 'result.list',  //数据
			totalProperty: 'result.total' //数据总条数
		}
	},
	sorters: [{
		property: 'ordeId',
		direction: 'desc'
	}],
	autoLoad:{start:0,limit:30},
});
//发票数据
var invoice = Ext.create('Ext.data.Store', {
		fields: ["code","amount"],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>costCheckList/findInvoice',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
var paymentNum = Ext.create('Ext.data.Store', {
	fields: ["paymentId",
	         "payment_app_code",
	     	"payment_bill_date",
	     	"payment_app_dept",
	    	"settlement_dept",
	    	"dept_business_type",
	    	"deposit_bank",
	    	"bank_account",
	    	"remark",
	    	"currency"],
	pageSize: 10,  //页容量5条数据
	//是否在服务端排序 （true的话，在客户端就不能排序）
	remoteSort: false,
	remoteFilter: true,
	proxy: {
		type: 'ajax',
		url: '<%=basePath%>costCheckList/findPaymentNum?is_income_loan='+"1",
		reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
			type: 'json', //返回数据类型为json格式
			root: 'result.list',  //数据
			totalProperty: 'result.total' //数据总条数
		}
	},
	sorters: [{
		property: 'ordeId',
		direction: 'desc'
	}],
	autoLoad:{start:0,limit:10},
});
//部门数据
var department = Ext.create('Ext.data.Store', {
		fields: ["DEPARTMENT_NAME"],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>costCheckList/findDepartment',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
//托单编号数据
var billCodeData = Ext.create('Ext.data.Store', {
		fields: ["BILL_CODE"],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>costCheckList/findBillCode',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	  var c2 = Ext.create('Ext.container.Container', {
			layout: 'column',
//			defaults: { labelAlign: 'left', labelWidth: 80 },
			items: [
				{id:"heji",xtype: 'textfield',labelWidth: 90, name: 'heji', columnWidth:  1/5,padding: '5px',hidden:true},
				{id:"heji1",xtype: 'textfield',labelWidth: 90, name: 'heji1', columnWidth:  1/5,padding: '5px',hidden:true},
				{id:"heji222",xtype: 'textfield',labelWidth: 90, name: 'heji2', columnWidth:  1/5,padding: '5px',hidden:true},
				{id:"paymentId",xtype: 'textfield',labelWidth: 90, name: 'paymentId', columnWidth:  1/5,padding: '5px',hidden:true},
				{id:"payment_app_code",xtype: 'textfield', labelWidth: 70,name: 'payment_app_code',columnWidth: 1/5,padding: '5px',fieldLabel: '付款单号'},
				{ columnWidth: 1/10,xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "查询导入",handler: function(){
					fandDao.show();
			      	 } },
			      	{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 4/5,  padding: '10px'},
				{id:"payment_bill_date",xtype: 'datefield',labelWidth: 70, name: 'payment_bill_date', columnWidth:  1/5,padding: '5px',fieldLabel: '制单日期'},
				{id:"payment_app_dept",xtype: 'combo',labelWidth: 70, store:department,displayField:'DEPARTMENT_NAME',name: 'payment_app_dept', columnWidth:  1/5,padding: '5px', fieldLabel: '部门'},
				{id:"dept_business_type",xtype: 'combo',labelWidth: 70, store:businessType,name: 'dept_business_type',displayField:'name',valueField:'id', columnWidth:  1/5,padding: '5px', fieldLabel: '业务类型'},
				{id:"startDate1",xtype: 'textfield',labelWidth: 70, name: 'startDate1', columnWidth:  1/5,padding: '5px', fieldLabel: '收款单位'},
				{id:"startDate2",xtype: 'textfield',labelWidth: 70, name: 'startDate2',columnWidth: 1/5,padding: '5px',fieldLabel: '开户银行'},
				{id:"startDate3",xtype: 'textfield', labelWidth: 70,name: 'startDate3',columnWidth: 1/5,padding: '5px',fieldLabel: '银行账号'},
				{id:"currency",xtype: 'combo', labelWidth: 70,name: 'currency',columnWidth: 1/5,store:currency,padding: '5px',displayField:'name',valueField:'id',fieldLabel: '币种'},
				{id:"startDate4",xtype: 'textarea',labelWidth: 120, name: 'startDate4',columnWidth: 1/5,padding: '5px',fieldLabel: '备注（付款期限）'},

			]
		});
	  
	  var bs2 = Ext.create('Ext.container.Container', {
			layout: 'column',
			items: [
				{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 2/5,   padding: '10px'},
				{layout : 'column',baseCls : 'my-panel-no-border',columnWidth: 2/5,  padding: '10px',  items: [
					{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "新增",handler: function(){


						Ext.getCmp('grid').getStore().insert(store.getCount(),{
			       				xh:store.getCount(),invoice_code:'',bill_code:'',payment_amount:'',fee_name:'',loan_odd_code:'',loan_date:'',loan_amount:'',remark:'',
			       			});
				      	 } },
				      	{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/add.png', text: "保存",handler: function(){
				      		var payment_app_code = Ext.getCmp("payment_app_code").getValue(); 
				      		var settlement_dept= Ext.getCmp("startDate1").getValue(); 
				      		var deposit_bank= Ext.getCmp("startDate2").getValue(); 
				      		var bank_account= Ext.getCmp("startDate3").getValue(); 
				      		var payment_term= Ext.getCmp("startDate4").getValue(); 
				      		var payment_bill_date= Ext.getCmp("payment_bill_date").getValue(); 
				      		var payment_app_dept= Ext.getCmp("payment_app_dept").getValue(); paymentId
				      		var dept_business_type= Ext.getCmp("dept_business_type").getValue();
				      		var actual_amount = Ext.getCmp("heji222").getValue();
// 				      		var remark= Ext.getCmp("remark").getValue();
				      		var paymentId= Ext.getCmp("paymentId").getValue();remark
				      		var currency= "";
				      		if(Ext.getCmp("currency").getValue()==1){
				      			currency="RMB"
				      		}else if(Ext.getCmp("currency").getValue()==0){
				      			currency="USD"
				      		}else{
				      			currency=""
				      		}
				      		
				      		
				      		var gridValue = Ext.getCmp("grid").getStore();
				      		var arr = [];
				      		 for (var i = 0; i < gridValue.data.length; i++) {
				      			var row = gridValue.getAt(i); 
				      			var id = "";
				      			if(row.get("id")!=null && row.get("id")!=""){
				      				var id = row.get("id");
				      			}
				      			var loan_id = null;
				      			if(row.get("loan_id")!=null && row.get("loan_id")!=""){
				      				loan_id = row.get("loan_id");
				      			}else{
				      				loan_id=null;
				      			}
				      			var invoice_code = row.get("invoice_code");
// 				      			if(invoice_code==null){
// 				      				invoice_code = '';
// 				      			}
				      			var bill_code = row.get("bill_code");
				      			var payment_amount = row.get("payment_amount");
				      			var fee_name = row.get("fee_name");
				      			var loan_odd_code = row.get("loan_odd_code");
				      			var loan_date = row.get("loan_date");
				      			var loan_amount = row.get("loan_amount");
				      			var remark = row.get("remark");
				      			obj = {
				      					id:id,
				      					loan_id:loan_id,
				      					currency:currency,
				      					payment_app_code:payment_app_code,
				      					invoice_code:invoice_code,
				      					bill_code:bill_code,
				      					payment_amount:payment_amount,
				      					fee_name:fee_name,
				      					loan_odd_code:loan_odd_code,
				      					loan_date:loan_date,
				      					loan_amount:loan_amount,
				      					receipt_code:"",
				      					receipt_date:"",
				      					receipt_amount:"",
				      					remark:remark
				      					
				      			}
				      			arr.push(obj)
				      		 }
				      		var array = JSON.stringify(arr);
					      		Ext.Ajax.request({
					      			 url: '<%=basePath%>costCheckList/saveInfo',
					      			 params:{array:array,is_loan:"1",settlement_dept:settlement_dept,deposit_bank:deposit_bank,bank_account:bank_account,remark:payment_term,payment_bill_date:payment_bill_date,payment_app_dept:payment_app_dept,
					      				 dept_business_type:dept_business_type,payment_app_code:payment_app_code,paymentId:paymentId,currency:currency,actual_amount:actual_amount},
					      			 method: 'POST',
					        			success: function () {
// 											Ext.getCmp("startDate1").setValue(null); 
// 											Ext.getCmp("startDate2").setValue(null); 
// 											Ext.getCmp("startDate3").setValue(null); 
// 											Ext.getCmp("startDate4").setValue(null);
// 											Ext.getCmp("payment_bill_date").setValue(null); 
// 											Ext.getCmp("payment_app_dept").setValue(null); 
// 											Ext.getCmp("dept_business_type").setValue(null);
// 											store1.load();
// 											store.load();
											 Ext.MessageBox.alert("保存成功","保存成功");
											 store.load();
											
					        			}
					      		});
				      	},
				      	},{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "刷新",handler: function(){

				      		javascript:location.reload();
					      	 } }


				],},
				{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 2/5,  padding: '10px'}
			]
		});
	  var invoice_code = new Ext.form.TextField({  
		  allowBlank : false,  
		  maxLength : 120  
		  });  
		  var bill_code = new Ext.form.TextField({  
		  allowBlank : false,  
		  maxLength : 120  
		  });  
		  var payment_amount = new Ext.form.TextField({  
			  id:'payment_amount',
		  allowBlank : false,  
		  maxLength : 120,
		  listeners:{
              blur: function(){
              	tt();
              } , 
          }
		  });  
// 		  var heji = new Ext.form.TextField({ 
// 			  id:'heji',
// 			  allowBlank : false,  
// 			  maxLength : 120  
// 			  });
		  var fee_name = new Ext.form.TextField({  
		  allowBlank : false,  
		  maxLength : 120  
		  });  
		  var loan_odd_num = new Ext.form.TextField({  
			  allowBlank : false,  
			  maxLength : 120  
			  }); 
		  var loan_date = new Ext.form.DateField({  
			  allowBlank : false,  
			  maxLength : 120  
			  }); 
		  var loan_amount = new Ext.form.TextField({  
			  allowBlank : false,  
			  maxLength : 120,
			  id:"loan_amount",
			  listeners:{ 
	              blur: function(){
	            	  var str = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
	            	  if(!str.test(Ext.getCmp("loan_amount").getValue())){
	            		  
	            		  Ext.MessageBox.alert("提示","只能输入数字和小数"); 
	            		  return false;
	            	  }
	              } , 
	          }
			  }); 
		  var remark = new Ext.form.TextField({  
			  allowBlank : false,  
			  maxLength : 120  
			  });
		  var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
			    clicksToMoveEditor: 1,
			    autoCancel: false
			});
		  var invoice_unit_cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 2});
		var grid = Ext.create('Ext.grid.Panel', {
// 	 		renderTo:'payment1',
			store: store,
			id:'grid',
			forceFit: true,
			height: 250,
// 			title:'成本付款审核单',
			stripeRows:true,
			 features: [{  
	                ftype: 'summary'  
	            }], 
			columnLines: true,
			plugins: [invoice_unit_cellEditing],
			selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
			columns: [
				{text: 'id', dataIndex: 'id',hidden:true},
				{text: 'loan_id', dataIndex: 'loan_id',hidden:true},
				{text: 'is_cost_audit', dataIndex: 'is_cost_audit',hidden:true},
				{text: '发票号', dataIndex: 'invoice_code',editor: {
			        xtype: 'combo',
			        typeAhead: true,
			        triggerAction: 'all',
			        id:'in',
			        selectOnTab: true,
			        lazyRender: true,
			        forceSelection: true,
			        editable: false,
// 			        valueField:'amount',
			        store: invoice,
			        displayField:'code',
			        listeners: {
			            'select': function (combo,record,index) {
			            	Ext.getCmp("payment_amount").setValue(record[0].data.amount);
			            },
					 
			        }
			    }},
				{text: '业务号', summaryRenderer: function (value, summaryData, dataIndex) {
					
		        	return Ext.String.format('合计金额：');  
                },dataIndex: 'bill_code',editor:{
			        xtype: 'combo',
			        typeAhead: true,
			        triggerAction: 'all',
			        selectOnTab: true,
			        lazyRender: true,
			        forceSelection: true,
			        editable: false,
			        store: billCodeData,
			        displayField:'BILL_CODE',
			        
			        listeners: {
			            change: function () {
// 			                alert("dddd");
			            }
			        }
			    },},
				{text: '成本付款金额', dataIndex: 'payment_amount',summaryRenderer: function (value, summaryData, dataIndex) {
					var aa= grid.getStore()  
					  var comValue = 0;
					  for(var i=0;i<aa.getCount();i++)
					  {
					     comValue+=parseInt(grid.getStore().data.items[i].data.payment_amount);
					  }
					  Ext.getCmp("heji").setValue(isNaN(comValue)?0:comValue);
// 					  alert(comValue);
                    return isNaN(comValue)?0:comValue
                }, editor:new Ext.form.TextField({  
					  id:'payment_amount',
// 					  allowBlank : false,  
					  maxLength : 120,
					  listeners:{ 
			              blur: function(){
			            	  var str = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
			            	  if(!str.test(Ext.getCmp("payment_amount").getValue())){
			            		  
			            		  Ext.MessageBox.alert("提示","只能输入数字和小数"); 
			            		  return false;
			            	  }
			              	var task = new Ext.util.DelayedTask(function(){
							    tt()
							});
							task.delay(500);
			              } , 
			          }
					  }),
                	
				
				},
				{text: '费用项目', dataIndex: 'fee_name',editor:fee_name},
				{text: '借款单号', dataIndex: 'loan_odd_code',editor:loan_odd_num,},
				{text: '借款日期', dataIndex: 'loan_date',summaryRenderer: function (value, summaryData, dataIndex) {
					
		        	return Ext.String.format('合计金额：');  
                },editor:loan_date},
				{text: '借款金额', dataIndex: 'loan_amount',editor:loan_amount,summaryRenderer: function (value, summaryData, dataIndex) {
					var aa= grid.getStore()  
					  var comValue = 0;
					  for(var i=0;i<aa.getCount();i++)
					  {
					     comValue+=parseInt(grid.getStore().data.items[i].data.loan_amount);
					  }
					  Ext.getCmp("heji1").setValue(isNaN(comValue)?0:comValue);
//					  alert(comValue);
                  return isNaN(comValue)?0:comValue
              }},
				{text: '备注', dataIndex: 'remark',editor:remark,summaryRenderer: function (value, summaryData, dataIndex) {
// 					var aa= grid.getStore()  
// 					alert("1");
			var comValue =0;

			comValue = parseInt(Ext.getCmp("heji").getValue())-parseInt(Ext.getCmp("heji1").getValue());
			Ext.getCmp("heji2").setValue(isNaN(comValue)?0:comValue);
					 
// 					  for(var i=0;i<aa.getCount();i++)
// 					  {
// 					     comValue+=parseInt(grid.getStore().data.items[i].data.loan_amount);
// 					  }
					  
//					  alert(comValue);
                return   Ext.String.format('实际金额：'+comValue);
            }},

				
			],listeners:{  
				//单击  
			       'cellclick' : function(grid,row){  
			    	   var records = grid.getSelectionModel().getSelection();
// 			    	   alert(records[0].data.is_cost_audit);
			    	   if(records[0].data.is_cost_audit==1){
			    		   Ext.MessageBox.alert("提示","已审核不能修改"); 
			    	   }
			       },  
			   } 
// 			bbar: [{
// 				xtype: 'pagingtoolbar',
// //	 			store: store,
// 				displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
// 				emptyMsg: "没有数据",
// 				beforePageText: "当前页",
// 				afterPageText: "共{0}页",
// 				displayInfo: true
// 			}]
		});
// 		var gridView = Ext.create('Ext.grid.Panel', {
// // 	 		renderTo:'payment2',
// 			store: store1,
// 			id:'gridView',
// 			forceFit: true,
// 			height: 250,
// 			title:'成本付款审核单',
// 			stripeRows:true,
// 			 features: [{  
// 	                ftype: 'summary'  
// 	            }],  
// 			columnLines: true,
// 			selModel:Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
// 			columns: [
// 				{text: 'id', dataIndex: 'id',hidden:true},
// 				{text: '发票号', dataIndex: 'invoice_code'},
// 				{text: '业务号', dataIndex: 'bill_code', summaryRenderer: function (value, summaryData, dataIndex) {
                	
//                     return Ext.String.format('合计金额：', value, value !== 1 ? 's' : '');  
//                 }},
// 				{text: '成本付款金额', dataIndex: 'payment_amount', 
// 			    	summaryType: 'sum',  
// 				},
// 				{text: '费用项目', dataIndex: 'fee_name'},
// 				{text: '借款单号', dataIndex: 'loan_odd_code'},
// 				{text: '借款日期', dataIndex: 'loan_date',render:Ext.util.Format.dateRenderer('Y-m-d')},
// 				{text: '借款金额', dataIndex: 'loan_amount'},
// 				{text: '备注', dataIndex: 'remark'},
// 				{text: '收款单位', dataIndex: 'settlement_dept'},
// 				{text: '开户银行', dataIndex: 'deposit_bank'},
// 				{text: '银行账户', dataIndex: 'bank_account'},
// 				{text: '备注（付款期限）', dataIndex: 'payment_term'},

				
// 			],
// 			bbar: [{
// 				xtype: 'pagingtoolbar',
// //	 			store: store,
// 				displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
// 				emptyMsg: "没有数据",
// 				beforePageText: "当前页",
// 				afterPageText: "共{0}页",
// 				displayInfo: true
// 			}]
// 		});
		
		var grid1 = Ext.create('Ext.grid.Panel', {
// 	 		renderTo:'payment2',
			store: paymentNum,
			id:'gridView',
			forceFit: true,
			height: 250,
// 			title:'成本付款审核单',
			stripeRows:true, 
			columnLines: true,
			selModel:Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
			columns: [
				{text: 'paymentId', dataIndex: 'paymentId',hidden:true},
				{text: '付款单号', dataIndex: 'payment_app_code'},
				{text: '制单日期', dataIndex: 'payment_bill_date'},
				{text: '部门', dataIndex: 'payment_app_dept'},
				{text: '业务类型', dataIndex: 'dept_business_type'},
				{text: '收款单位', dataIndex: 'settlement_dept'},
				{text: '开户银行', dataIndex: 'deposit_bank'},
				{text: '银行账号', dataIndex: 'bank_account'},
				{text: '备注', dataIndex: 'remark'},
			],
			bbar: [{
				xtype: 'pagingtoolbar',
	 			store: paymentNum,
				displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
				emptyMsg: "没有数据",
				beforePageText: "当前页",
				afterPageText: "共{0}页",
				displayInfo: true,
				pageSize:10
			}],
			listeners:{  
				//单击  
				       'cellclick' : function(grid,row){  
				    	   var records = grid.getSelectionModel().getSelection();
				    	   Ext.getCmp("payment_app_code").setValue(records[0].data.payment_app_code);
				    	   Ext.getCmp("payment_bill_date").setValue(Ext.util.Format.date(records[0].data.payment_bill_date, "Y-m-d"));
				    	   Ext.getCmp("payment_app_dept").setValue(records[0].data.payment_app_dept);
				    	   Ext.getCmp("dept_business_type").setValue(records[0].data.dept_business_type);
				    	   Ext.getCmp("startDate1").setValue(records[0].data.settlement_dept);
				    	   Ext.getCmp("startDate2").setValue(records[0].data.deposit_bank);
				    	   Ext.getCmp("paymentId").setValue(records[0].data.paymentId);
				    	   Ext.getCmp("startDate3").setValue(records[0].data.bank_account);
				    	   Ext.getCmp("startDate4").setValue(records[0].data.remark);
				    	   Ext.getCmp("currency").setValue(records[0].data.currency);
				    	   store.on('beforeload', function(store,options) {  
					            var new_params = {  
					            		payment_app_code:records[0].data.payment_app_code,
					            		is_income_loan:1
					            }; 
					            Ext.apply(store.proxy.extraParams,new_params);  
					        });
					        store.load(); 
				    	   fandDao.close();
				       },  
				   }  
		});
		
		var fandDao = Ext.create("Ext.window.Window",{
				title: "付款单号",
				modal:true,
				/*width: 800,
				height: 360,*/
				maximizable: true,
			    closeAction: 'hide',
				//closeAction:'destroy',
				layout: "fit",
//				margin: '3 3 0',
		        buttonAlign:'center',
		        items: [grid1]
		});
		
		
		
		  var selForm = Ext.create('Ext.form.Panel', {
				title:'成本付款审核单',
				name: 'selForm',
// 				renderTo:'payment',
				width:'100%',
//				collapsed :true,
				height:'96%',
//				collapsible:true,
				bodyStyle: {
					padding: '5px',
					border: 1
				},
				fieldDefaults: {
					labelAlign: 'left'
				},
				items: [c2,bs2]
			});
		  function tt(){
			  var aa= grid.getStore()  
			  var comValue = 0;
			  for(var i=0;i<aa.getCount();i++)
			  {
			     comValue+=parseInt(grid.getStore().data.items[i].data.payment_amount);
			  }
			  Ext.getCmp("heji").setValue(comValue);
		  }
			function exportFile(type){
				var rs=gridView.getSelectionModel().getSelection();
// 				var arr = [];
				var ids = "";
       			Ext.each(rs,function(item){
       				ids+= item.data.id+",";
       			});
			    document.location.href="<%=basePath%>common/export/exportExcel?exportType="+type+"&ids="+ids;
			}
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			

			var paymentNum1 = Ext.create('Ext.data.Store', {
				fields: ["paymentId",
				         "payment_app_code",
				     	"payment_bill_date",
				     	"payment_app_dept",
				    	"settlement_dept",
				    	"dept_business_type",
				    	"deposit_bank",
				    	"bank_account",
				    	"remark",
				    	"currency"],
				pageSize: 30,  //页容量5条数据
				//是否在服务端排序 （true的话，在客户端就不能排序）
				remoteSort: false,
				remoteFilter: true,
				proxy: {
					type: 'ajax',
					url: '<%=basePath%>costCheckList/findPaymentInfoWhere?is_income_loan='+"0",
					reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
						type: 'json', //返回数据类型为json格式
						root: 'result.list',  //数据
						totalProperty: 'result.total' //数据总条数
					}
				},
				sorters: [{
					property: 'ordeId',
					direction: 'desc'
				}],
				autoLoad: true
			});
			
			
			 var c3 = Ext.create('Ext.container.Container', {
					layout: 'column',
//					defaults: { labelAlign: 'left', labelWidth: 80 },
					items: [
						{id:"heji2",xtype: 'textfield',labelWidth: 90, name: 'heji2', columnWidth:  1/5,padding: '5px',hidden:true},
						{id:"heji11",xtype: 'textfield',labelWidth: 90, name: 'heji11', columnWidth:  1/5,padding: '5px',hidden:true},
						{id:"heji123",xtype: 'textfield',labelWidth: 90, name: 'heji11', columnWidth:  1/5,padding: '5px',hidden:true},
						{id:"paymentId1",xtype: 'textfield',labelWidth: 90, name: 'paymentId1', columnWidth:  1/5,padding: '5px',hidden:true},
						{id:"payment_app_code1",xtype: 'textfield', labelWidth: 70,name: 'payment_app_code',columnWidth: 1/5,padding: '5px',fieldLabel: '付款单号'},
						{ columnWidth: 1/10,xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "查询导入",handler: function(){
// 							fandaoView();
							fandDao1.show();
					      	 } },
					      	{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 4/5,  padding: '10px'},
						{id:"payment_bill_date1",xtype: 'datefield',labelWidth: 70, name: 'payment_bill_date1', columnWidth:  1/5,padding: '5px', fieldLabel: '制单日期'},
						{id:"payment_app_dept1",xtype: 'combo',labelWidth: 70, store:department,displayField:'DEPARTMENT_NAME',name: 'payment_app_dept1', columnWidth:  1/5,padding: '5px', fieldLabel: '部门'},
						{id:"dept_business_type1",xtype: 'combo',labelWidth: 70, store:businessType,name: 'dept_business_type1',displayField:'name',valueField:'id', columnWidth:  1/5,padding: '5px', fieldLabel: '业务类型'},
						{id:"startDate11",xtype: 'textfield',labelWidth: 70, name: 'startDate11', columnWidth:  1/5,padding: '5px', fieldLabel: '收款单位'},
						{id:"startDate21",xtype: 'textfield',labelWidth: 70, name: 'startDate21',columnWidth: 1/5,padding: '5px',fieldLabel: '开户银行'},
						{id:"startDate31",xtype: 'textfield', labelWidth: 70,name: 'startDate31',columnWidth: 1/5,padding: '5px',fieldLabel: '银行账号'},
						{id:"currency1",xtype: 'combo', labelWidth: 70,name: 'currency1',columnWidth: 1/5,store:currency,padding: '5px',displayField:'name',valueField:'id',fieldLabel: '币种'},
						{id:"startDate41",xtype: 'textarea',labelWidth: 120, name: 'startDate41',columnWidth: 1/5,padding: '5px',fieldLabel: '备注（付款期限）'},

					]
				});
			  
			  var bs3 = Ext.create('Ext.container.Container', {
					layout: 'column',
					items: [
						{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 2/5,   padding: '10px'},
						{layout : 'column',baseCls : 'my-panel-no-border',columnWidth: 2/5,  padding: '10px',  items: [
							{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "新增",handler: function(){


								Ext.getCmp('grid1').getStore().insert(store2.getCount(),{
					       				xh:store2.getCount(),invoice_code:'',bill_code:'',payment_amount:'',fee_name:'',receipt_code:'',receipt_date:'',receipt_amount:'',remark:'',
					       			});
						      	 } },
						      	{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/add.png', text: "保存",handler: function(){
						      		var settlement_dept= Ext.getCmp("startDate11").getValue(); 
						      		var deposit_bank= Ext.getCmp("startDate21").getValue(); 
						      		var bank_account= Ext.getCmp("startDate31").getValue(); 
						      		var payment_term= Ext.getCmp("startDate41").getValue(); 
						      		var payment_bill_date= Ext.getCmp("payment_bill_date1").getValue(); 
						      		var payment_app_dept= Ext.getCmp("payment_app_dept1").getValue(); 
						      		var dept_business_type= Ext.getCmp("dept_business_type1").getValue(); 
						      		var payment_app_code = Ext.getCmp("payment_app_code1").getValue();
						      		var currency = Ext.getCmp("currency1").getValue();
						      		var paymentId = Ext.getCmp("paymentId1").getValue();
						      		
						      		var gridValue = Ext.getCmp("grid1").getStore();
						      		var arr = [];
						      		 for (var i = 0; i < gridValue.data.length; i++) {
						      			var row = gridValue.getAt(i); 
// 						      			var id = "";
										var costId = "";
						      			if(row.get("costId")!=null && row.get("costId")!=""){
						      				costId = row.get("costId");
						      			}
						      			var incomeId = "";
						      			if(row.get("incomeId")!=null && row.get("incomeId")!=""){
						      				incomeId = row.get("incomeId");
						      			}
						      			var invoice_code = row.get("invoice_code");  
						      			var bill_code = row.get("bill_code");
						      			var payment_amount = row.get("payment_amount");
						      			var fee_name = row.get("fee_name");
						      			
						      			var receipt_code = row.get("receipt_code");
						      			var receipt_date = row.get("receipt_date");
						      			var receipt_amount = row.get("receipt_amount");
						      			var remark = row.get("remark");
						      			var actual_amount = Ext.getCmp("heji123").getValue();
						      			obj = {
// 						      					id:id,
						      					costId:costId,
						      					incomeId:incomeId,
						      					invoice_code:invoice_code,
						      					bill_code:bill_code,
						      					payment_amount:payment_amount,
						      					fee_name:fee_name,
						      					loan_odd_code:"",
						      					loan_date:"",
						      					loan_amount:"",
						      					receipt_code:receipt_code,
						      					receipt_date:receipt_date,
						      					receipt_amount:receipt_amount,
						      					payment_app_code:payment_app_code,
						      					currency:currency,
						      					remark:remark
						      			}
						      			arr.push(obj)
						      		 }
						      		var array = JSON.stringify(arr);
							      		Ext.Ajax.request({
							      			 url: '<%=basePath%>costCheckList/saveIncomeInfo',
							      			 params:{array:array,is_loan:"2",paymentId:paymentId,payment_app_code:payment_app_code,incomeId:incomeId,costId:costId,settlement_dept:settlement_dept,deposit_bank:deposit_bank,bank_account:bank_account,remark:payment_term,payment_bill_date:payment_bill_date,
							      				 payment_app_dept:payment_app_dept,dept_business_type:dept_business_type,currency:currency,actual_amount:actual_amount},
							      			 method: 'POST',
							        			success: function () {
// 													Ext.getCmp("startDate11").setValue(null); 
// 													Ext.getCmp("startDate21").setValue(null); 
// 													Ext.getCmp("startDate31").setValue(null); 
// 													Ext.getCmp("startDate41").setValue(null);
// 													Ext.getCmp("payment_bill_date1").setValue(null); 
// 													Ext.getCmp("payment_app_dept1").setValue(null); 
// 													Ext.getCmp("dept_business_type1").setValue(null);
// 													store1.load();
// 													store2.load();
													
							        				Ext.MessageBox.alert("保存成功","保存成功");
							        				store.load();
// 													javascript:location.reload();
													
							        			}
							      		});
						      	},
						      	},{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/table_refresh.png', text: "刷新",handler: function(){

						      		javascript:location.reload();
							      	 } },


						],},
						{layout : 'column',baseCls : 'my-panel-no-border', columnWidth: 2/5,  padding: '10px'}
					]
				});
			  var invoice_code1 = new Ext.form.TextField({  
				  allowBlank : false,  
				  maxLength : 120  
				  });  
				  var bill_code1 = new Ext.form.TextField({  
				  allowBlank : false,  
				  maxLength : 120  
				  });  
				  var payment_amount1 = new Ext.form.TextField({  
				  allowBlank : false,  
				  maxLength : 120,
				  listeners:{
		              blur: function(){
		            	 
		              	tt();
		              } , 
		          }
				  });  
//		 		  var heji = new Ext.form.TextField({ 
//		 			  id:'heji',
//		 			  allowBlank : false,  
//		 			  maxLength : 120  
//		 			  });
				  var fee_name1 = new Ext.form.TextField({  
				  allowBlank : false,  
				  maxLength : 120  
				  });  
				  var loan_odd_num1 = new Ext.form.TextField({  
					  allowBlank : false,  
					  maxLength : 120  
					  }); 
				  var loan_date1 = new Ext.form.DateField({  
					  allowBlank : false,  
					  maxLength : 120  
					  }); 
				  var loan_amount1 = new Ext.form.TextField({  
					  allowBlank : false,  
					  maxLength : 120,
					  id:'loan_amount1',
					  listeners:{ 
			              blur: function(){
			            	  var str = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
			            	  if(!str.test(Ext.getCmp("loan_amount1").getValue())){
			            		  
			            		  Ext.MessageBox.alert("提示","只能输入数字和小数"); 
			            		  return false;
			            	  }
			              } , 
			          }
					  }); 
				  var remark1 = new Ext.form.TextField({  
					  allowBlank : false,  
					  maxLength : 120  
					  });
				  var rowEditing1 = Ext.create('Ext.grid.plugin.RowEditing', {
					    clicksToMoveEditor: 1,
					    autoCancel: false
					});
				  var invoice_unit_cellEditing1 = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 2});
				var grid1 = Ext.create('Ext.grid.Panel', {
// 			 		renderTo:'payment1',
					store: store2,
					id:'grid1',
					forceFit: true,
					height: 250,
//		 			title:'成本付款审核单',
					stripeRows:true,
					 features: [{  
			                ftype: 'summary'  
			            }], 
					columnLines: true,
					plugins: [invoice_unit_cellEditing1],
					selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
					columns: [
						{text: 'costId', dataIndex: 'costId',hidden:true},
						{text: 'incomeId', dataIndex: 'incomeId',hidden:true},
						{text: '发票号', dataIndex: 'invoice_code',editor: {
					        xtype: 'combo',
					        typeAhead: true,
					        triggerAction: 'all',
					        id:'in1',
					        selectOnTab: true,
					        lazyRender: true,
					        forceSelection: true,
					        editable: false,
//		 			        valueField:'amount',
					        store: invoice,
					        displayField:'code',
					        listeners: {
					            'select': function (combo,record,index) {
					            	Ext.getCmp("payment_amount").setValue(record[0].data.amount);
					            }
					        }
					    }},
						{text: '业务号', summaryRenderer: function (value, summaryData, dataIndex) {
							
				        	return Ext.String.format('合计金额：');  
		                },dataIndex: 'bill_code',editor:{
					        xtype: 'combo',
					        typeAhead: true,
					        triggerAction: 'all',
					        selectOnTab: true,
					        lazyRender: true,
					        forceSelection: true,
					        editable: false,
					        store: billCodeData,
					        displayField:'BILL_CODE',
					        
					        listeners: {
					            change: function () {
//		 			                alert("dddd");
					            }
					        }
					    },},
						{text: '成本付款金额', dataIndex: 'payment_amount', summaryRenderer: function (value, summaryData, dataIndex) {
							var aa= grid1.getStore()  
							  var comValue = 0;
							  for(var i=0;i<aa.getCount();i++)
							  {
							     comValue+=parseInt(grid1.getStore().data.items[i].data.payment_amount);
							  }
							  Ext.getCmp("heji2").setValue(isNaN(comValue)?0:comValue);
//		 					  alert(comValue);
		                    return isNaN(comValue)?0:comValue
		                }, editor:new Ext.form.TextField({  
							  id:'payment_amount1',
							  allowBlank : false,  
							  maxLength : 120,
							  listeners:{ 
					              blur: function(){
					            	  var str = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
					            	  if(!str.test(Ext.getCmp("payment_amount1").getValue())){
					            		  
					            		  Ext.MessageBox.alert("提示","只能输入数字和小数"); 
					            		  return false;
					            	  }
					              	var task = new Ext.util.DelayedTask(function(){
									    tt()
									});
									task.delay(500);
					              } , 
					          }
							  }),
		                	
						
						},
						{text: '费用项目', dataIndex: 'fee_name',editor:fee_name1},
						{text: '发票号', dataIndex: 'receipt_code',editor: {
					        xtype: 'combo',
					        typeAhead: true,
					        triggerAction: 'all',
					        id:'in11',
					        selectOnTab: true,
					        lazyRender: true,
					        forceSelection: true,
					        editable: false,
//		 			        valueField:'amount',
					        store: invoice,
					        displayField:'code',
					        listeners: {
					            'select': function (combo,record,index) {
					            	Ext.getCmp("payment_amount").setValue(record[0].data.amount);
					            }
					        }
					    }},
						{text: '业务号', dataIndex: 'receipt_date',summaryRenderer: function (value, summaryData, dataIndex) {
							
				        	return Ext.String.format('合计金额：');  
		                },editor:{
					        xtype: 'combo',
					        typeAhead: true,
					        triggerAction: 'all',
					        selectOnTab: true,
					        lazyRender: true,
					        forceSelection: true,
					        editable: false,
					        store: billCodeData,
					        displayField:'BILL_CODE',
					        
					        listeners: {
					            change: function () {
//		 			                alert("dddd");
					            }
					        }
					    },},
						{text: '收款金额', dataIndex: 'receipt_amount',editor:loan_amount1,summaryRenderer: function (value, summaryData, dataIndex) {
							var aa= grid1.getStore()  
							  var comValue = 0;
							  for(var i=0;i<aa.getCount();i++)
							  {
							     comValue+=parseInt(grid1.getStore().data.items[i].data.receipt_amount);
							  }
							  Ext.getCmp("heji11").setValue(isNaN(comValue)?0:comValue);
//							  alert(comValue);
		                  return isNaN(comValue)?0:comValue
		              }},
						{text: '备注', dataIndex: 'remark',editor:remark1,summaryRenderer: function (value, summaryData, dataIndex) {
//		 					var aa= grid.getStore()  
		 					
				var comValue =0;
				comValue = parseInt(Ext.getCmp("heji2").getValue())-parseInt(Ext.getCmp("heji11").getValue());
				Ext.getCmp("heji123").setValue(isNaN(comValue)?0:comValue);
							 
//		 					  for(var i=0;i<aa.getCount();i++)
//		 					  {
//		 					     comValue+=parseInt(grid.getStore().data.items[i].data.loan_amount);
//		 					  }
							  
//							  alert(comValue);
		                return   Ext.String.format('实际金额：'+comValue);
		            }},

						
					],
					listeners:{  
						//单击  
					       'cellclick' : function(grid,row){  
					    	   var records = grid1.getSelectionModel().getSelection();
//		 			    	   alert(records[0].data.is_cost_audit);
					    	   if(records[0].data.is_cost_audit==1){
					    		   Ext.MessageBox.alert("提示","已审核不能修改"); 
					    	   }
					       },  
					   } 
//		 			bbar: [{
//		 				xtype: 'pagingtoolbar',
		// //	 			store: store,
//		 				displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
//		 				emptyMsg: "没有数据",
//		 				beforePageText: "当前页",
//		 				afterPageText: "共{0}页",
//		 				displayInfo: true
//		 			}]
				});
				var grid2 = Ext.create('Ext.grid.Panel', {
//		 	 		renderTo:'payment2',
					store: paymentNum1,
					id:'grid2',
					forceFit: true,
					height: 250,
//		 			title:'成本付款审核单',
					stripeRows:true, 
					columnLines: true,
					selModel:Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
					columns: [
						{text: 'id', dataIndex: 'id',hidden:true},
						{text: '付款单号', dataIndex: 'payment_app_code'},
						{text: '制单日期', dataIndex: 'payment_bill_date'},
						{text: '部门', dataIndex: 'payment_app_dept'},
						{text: '业务类型', dataIndex: 'dept_business_type'},
						{text: '收款单位', dataIndex: 'settlement_dept'},
						{text: '开户银行', dataIndex: 'deposit_bank'},
						{text: '银行账号', dataIndex: 'bank_account'},
						{text: '备注', dataIndex: 'remark'},
					],
					bbar: [{
						xtype: 'pagingtoolbar',
//			 			store: store,
						displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
						emptyMsg: "没有数据",
						beforePageText: "当前页",
						afterPageText: "共{0}页",
						displayInfo: true
					}],
					listeners:{  
						//单击  
						       'cellclick' : function(grid,row){  
						    	   var records = grid2.getSelectionModel().getSelection();
						    	   Ext.getCmp("payment_app_code1").setValue(records[0].data.payment_app_code);
						    	   Ext.getCmp("payment_bill_date1").setValue(Ext.util.Format.date(records[0].data.payment_bill_date, "Y-m-d"));
						    	   Ext.getCmp("payment_app_dept1").setValue(records[0].data.payment_app_dept);
						    	   Ext.getCmp("dept_business_type1").setValue(records[0].data.dept_business_type);
						    	   Ext.getCmp("startDate11").setValue(records[0].data.settlement_dept);
						    	   Ext.getCmp("startDate21").setValue(records[0].data.deposit_bank);
						    	   
						    	   Ext.getCmp("startDate31").setValue(records[0].data.bank_account);
						    	   Ext.getCmp("startDate41").setValue(records[0].data.remark);
						    	   Ext.getCmp("currency1").setValue(records[0].data.currency);
						    	   Ext.getCmp("paymentId1").setValue(records[0].data.paymentId);
						    	   
						    		
						    	   store2.on('beforeload', function(store,options) {  
							            var new_params = {  
							            		payment_app_code:records[0].data.payment_app_code,
							            		is_income_loan:0
							            }; 
							            Ext.apply(store2.proxy.extraParams,new_params);  
							        });
						    	   store2.load(); 
						    	   fandDao1.close();
						       },  
						   }  
				});
// 				function fandaoView(){
					
// 				}
				var fandDao1 = Ext.create("Ext.window.Window",{
					title: "付款单号",
					modal:true,
// 					closeAction : 'close',
					closeAction : "hide",
					/*width: 800,
					height: 360,*/
					maximizable: true,
					//closeAction:'destroy',
					layout: "fit",
//					margin: '3 3 0',
			        buttonAlign:'center',
			        items: [grid2]
			});
// 				var gridView1 = Ext.create('Ext.grid.Panel', {
// // 			 		renderTo:'payment21',
// 					store: store1,
// 					id:'gridView1',
// 					forceFit: true,
// 					height: 250,
// 					title:'成本付款审核单',
// 					stripeRows:true,
// 					 features: [{  
// 			                ftype: 'summary'  
// 			            }],  
// 					columnLines: true,
// 					selModel:Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}),
// 					columns: [
// 						{text: 'id', dataIndex: 'id',hidden:true},
// 						{text: '发票号', dataIndex: 'invoice_code'},
// 						{text: '业务号', dataIndex: 'bill_code', summaryRenderer: function (value, summaryData, dataIndex) {
		                	
// 		                    return Ext.String.format('合计金额：', value, value !== 1 ? 's' : '');  
// 		                }},
// 						{text: '成本付款金额', dataIndex: 'payment_amount', 
// 					    	summaryType: 'sum',  
// 						},
// 						{text: '费用项目', dataIndex: 'fee_name'},
// 						{text: '收款单号', dataIndex: 'receipt_code'},
// 						{text: '收款日期', dataIndex: 'receipt_date',render:Ext.util.Format.dateRenderer('Y-m-d')},
// 						{text: '收款金额', dataIndex: 'receipt_amount'},
// 						{text: '备注', dataIndex: 'remark'},
// 						{text: '收款单位', dataIndex: 'settlement_dept'},
// 						{text: '开户银行', dataIndex: 'deposit_bank'},
// 						{text: '银行账户', dataIndex: 'bank_account'},
// 						{text: '备注（付款期限）', dataIndex: 'payment_term'},

						
// 					],
// 					tbar: [
<%-- 							{text: '导出', icon: '<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/cog_edit.png', handler: function (){ --%>
// 								exportFile("costCheckList")
// 							}}
// 					       ],
// 					bbar: [{
// 						xtype: 'pagingtoolbar',
// //			 			store: store,
// 						displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
// 						emptyMsg: "没有数据",
// 						beforePageText: "当前页",
// 						afterPageText: "共{0}页",
// 						displayInfo: true
// 					}]
// 				});
				  var selForm1 = Ext.create('Ext.form.Panel', {
						title:'成本付款审核单',
						name: 'selForm1',
// 						renderTo:'payment11',
						width:'100%',
//						collapsed :true,
						height:'96%',
//						collapsible:true,
						bodyStyle: {
							padding: '5px',
							border: 1
						},
						fieldDefaults: {
							labelAlign: 'left'
						},
						items: [c3,bs3]
					});
			
			  var tabs = new Ext.TabPanel({
				  renderTo: Ext.getBody(),

		            activeTab:0,
		            deferredRender:true,

		            items: [
		                    { title: '借款',items:[selForm,grid],listeners: {  
		                        'show': function (t, eOpts) {  
// 		                           $("#grid-body").hide();
// 		                           $("#grid_header").hide();
		                        }  
		                    }  },
		                    { title: '收入',items:[selForm1,grid1],listeners: {  
		                        'show': function (t, eOpts) {  
// 		                        	$("#grid-body").hide();
// 		                        	$("#grid_header").hide();
		                        }  
		                    }  }
		            ]
		        });
			  function convertDate(val) {
					return Ext.util.Format.date(new Date(val), 'Y-m-d');
				}
			  
});

</script>
</html>